<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@page import="java.util.*"%>
<%@page import="com.srit.core.bean.Page" %>
<%@page import="com.srit.map.business.bean.Company" %>
<html>
<head>
<meta charset="utf-8">
<title>鄞州区经济地图</title>
<link rel="stylesheet" href="./css/reset.css">
<link rel="stylesheet" href="./css/css20121027.css">
<script src="./js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
<style type="text/css">
#allmap{width: 80%;height: 100%;overflow: hidden;margin:0;float:left}
#right{width:20%; height: 100%;overflow: hidden;margin:0;float:left;background-color:#FFFFFF;font-size:12px;}
.h-wrap{width:1024px;padding:16px 30px 0 30px;}
.icon_right{background:url(./image/markers.png);width:19px;height:25px;float:left;}
.foot{height:25px;width:100%;background-color:#DEEEF8;text-align:center;line-height:25px;}
</style>
<%
Page pages = (Page)request.getAttribute("page");
int len = 0;
int total = 0;
List<Company> companyList = new ArrayList<Company>();
if(pages.getList() != null){
	companyList = pages.getList();
	len = companyList.size();
	total = pages.getTotalNum();
}
%>
<script type="text/javascript">

</script>

</head>
<body>
<div class="app-main">
  <div class="app-header"></div>
  <div style="height:600px;margin:0 auto;padding:18px 0  11px 0;overflow:hidden;">
  	<div class="h-wrap">
          <form action="/map/pages/public/Map!searchByKey.do" method="post">
            <div class="f-pos"><div class="pos_s1"><label>名&nbsp;&nbsp;&nbsp;&nbsp;称：</label><input type="text" class="ipt-txt1" >
            </div>
            <div class="pos_s2">
                <label>注册资本：</label><input type="text" class="ipt-txt2">
              </div>
            </div>
            
            <div class="f-pos">
              <div class="pos_s1">
                <label>行&nbsp;&nbsp;&nbsp;&nbsp;业：</label><input type="text" class="ipt-txt2">
              </div>
              <div class="pos_s2">
                <label>路&nbsp;&nbsp;&nbsp;&nbsp;径：</label><input type="text" class="ipt-txt2">
              </div>
              <div class="pos_s2">
                <label>注册时间：</label><input type="text" class="ipt-txt2" id="datepicker">
              </div>
            </div>
            <div class="f-pos">
              <div class="pos_s1">
                <label>经济类型：</label><input type="text" class="ipt-txt2">
              </div>
              <div class="pos_s2">
                <label>经营范围：</label><input type="text" class="ipt-txt2">
              </div>
              <div class="f-pos-submit">
              <input type="submit" value="查 询" class="btn-query">
            </div>
            </div>
          </form>
        </div>
  	<div style="width:100%;height:100%">
		<div id="allmap"></div>
		<div id="right"><%=total %>个搜索结果
		<%for(int j = 0; j < len; j ++) {
			%>
			<div style="margin-top:6px">
				<div class="icon_right" ></div> 
				
			<div ><%=companyList.get(j).getName()%><br>地址：<%=companyList.get(j).getAddress()%></div>
			</div>
			<% 
		}%>
		<s:if test="page.pageNum>0">
		<s:a namespace="/pages/public" action="Map" method="searchByKey">
			<s:param name="page.pageNum" value="page.pageNum-1"></s:param>
			<s:param name="searchKey" value="page.sp.searchKey"></s:param>
								上一页
							</s:a>
		</s:if>
		<s:if test="page.pageNum<page.totalPage-1">
		<s:a namespace="/pages/public" action="Map" method="searchByKey">
			<s:param name="page.pageNum" value="page.pageNum+1"></s:param>
			<s:param name="searchKey" value="page.sp.searchKey"></s:param>
								下一页
							</s:a>
		</s:if>
		</div>
		
		</div>
	</div>
	<div class="foot">宁波市鄞州区经济和信息化局</div>
  </div>
<script>
$(document).ready(function(){
  $(".f-info tr:odd").css("background","#ffffff");
});
</script>
</body>
</html>
<script type="text/javascript">
var map = new BMap.Map("allmap");
var point = new BMap.Point(121.553433,29.8234865);
map.centerAndZoom(point, 12);
map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用

// 编写自定义函数,创建标注
//function addMarker(point){
  //var myIcon = new BMap.Icon("./image/markers.png", new BMap.Size(19,25));
  //myIcon.setImageOffset(new BMap.Size(0,-25));
  //var marker = new BMap.Marker(point,{icon:myIcon});
  //map.addOverlay(marker);
//}
// 随机向地图添加25个标注
//var bounds = map.getBounds();
//var sw = bounds.getSouthWest();
//var ne = bounds.getNorthEast();
//var lngSpan = Math.abs(sw.lng - ne.lng);
//var latSpan = Math.abs(ne.lat - sw.lat);
var marker = new Array(<%=len%>);
var infoWindow = new Array(<%=len%>);
<%
for(int i = 0; i < len; i ++) {%>
	var x='<%=companyList.get(i).getPost_long()%>';
	var y='<%=companyList.get(i).getPost_lat()%>';
	//alert(x+","+y)
	var j=<%=i%>*(-25);
	//alert(j);
 	var point = new BMap.Point(x, y);
 	var myIcon = new BMap.Icon("./image/markers.png", new BMap.Size(19,25));
 	myIcon.setAnchor(new BMap.Size(9.5,25));
 	myIcon.setImageOffset(new BMap.Size(0,j));
 	
 	marker[<%=i%>] = new BMap.Marker(point,{icon:myIcon});
 	map.addOverlay(marker[<%=i%>]);
 	
 	infoWindow[<%=i%>] = new BMap.InfoWindow('<div style="font-size:14px"><strong><%=companyList.get(i).getName()%></strong><br>地址：<%=companyList.get(i).getAddress()%></div>');
 	var k = '<%=companyList.get(i).getName()%>';
 	//alert(k)
 	marker[<%=i%>].openInfoWindow(infoWindow[<%=i%>]);
 	marker[<%=i%>].addEventListener("click", function(){this.openInfoWindow(infoWindow[<%=i%>]);});
 	map.setCenter(point);
 	
<%
}
%>
</script>
<!-- 右边标识切换 A B -->
				<script>
					$(document).ready(function(){
						for(i=0;i<<%=len%>;i++){
							k=-25*i;
							$(".icon_right").eq(i).css({"background-position":"-19px "+k+"px"});
						}
					});
				</script>
